using System;
using System.Configuration;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Web.Mail;



namespace AccountMailer.NET
{

	public class Start
	{



		[STAThread]
		static void Main(string[] args)
		{

			Console.WriteLine ("Starting Application");
			Console.WriteLine ("Current directory: " + Application.StartupPath.ToString());
			SmtpMail.SmtpServer = ConfigurationSettings.AppSettings["relay server"].ToString();
		
			DirectoryLookup dirLookup = new DirectoryLookup ();
			Console.WriteLine ("Getting account information");

            if (dirLookup.PerformSearch(int.Parse (ConfigurationSettings.AppSettings["expirationDays"]), ConfigurationSettings.AppSettings["domain"].ToString()) == false)
			{
				SmtpMail.Send (ConfigurationSettings.AppSettings["debug email"].ToString(), ConfigurationSettings.AppSettings["debug email"].ToString(), "AccountMailer problems (account retrieval)", "Look at event viewer at " + System.Environment.MachineName.ToString());

			}
			Console.WriteLine ("Sending emails");
			if (dirLookup.SendEmail()==false)
			{
				SmtpMail.Send (ConfigurationSettings.AppSettings["debug email"].ToString(), ConfigurationSettings.AppSettings["debug email"].ToString(), "AccountMailer problems (email sending)", "Look at event viewer at " + System.Environment.MachineName.ToString());
			}
		}

		

	}
}
